WARNING : This program has a bug, which means we need to fix it.
RULE: New sprites appear at ( 0 , 0 ) . We can use Go To commands to send them to another part of the stage.
Click Run to see the what's wrong.
Change the numbers in the .go_to() command so that the sprite in the middle goes to the goal sprite.
To navigate the page using the TAB key, first press ESC to exit the code editor.
color = "black"
stage.create_grid_overlay(50, 'black')
image = codesters.Sprite("person16", 200, 100 )
image.set_opacity(.5)
image.set_size(.5)
text = codesters.Text('goal sprite', 200, 175, "purple")
text.set_size(.8)
point = codesters.Point(200, 100, 10, "purple")
sprite = codesters.Sprite("person16")
sprite.set_size(.5)
sprite.go_to(0, 0)
try:
tval1 = sprite.get_x()
tval2 = sprite.get_y()
except:
tval1 = "DNE"
tval2 = "DNE"
t1 = TestObjective()
t1.add_success(tval1 == 200 and tval2 == 100, "Great job debugging the program!")
t1.add_failure(tval1 == "DNE" or tval2 == "DNE", "Oops! Did you delete the sprite?")
t1.add_failure(tval1 != 200, "Try finding the x-coordinate of the purple dot!")
t1.add_failure(tval2 != 100, "Try finding the y-coordinate of the purple dot!")
tester = TestManager()
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()
Run Code
Activity Submitted!
Submit Work
Next Activity
Stop Running Code
Show Chart
Show Console
Reset Code Editor
Codesters How To (opens in a new tab)